<?php

namespace backend\models\mall\special;

use Yii;
use common\models\mall\special\MallSpecialModel;

/**
 * 专题
 */
class MallSpecial extends MallSpecialModel
{
    /**
     * Adds an additional WHERE condition to the existing one.
     * @param \yii\db\Query $query
     * @param array $params
     * @param string $alias
     */
    public static function setQuery(&$query, $params, $alias = '')
    {
        if ($alias) $alias .= '.';

        // 检索条件
        if (!empty($params['name'])) {
            $query->andWhere(['like', $alias .'name', $params['name']]);
        }
        if (!empty($params['code'])) {
            $query->andWhere(['=', $alias .'code', $params['code']]);
        }
        if (!empty($params['state'])) {
            $query->andWhere(['=', $alias .'state', $params['state']]);
        }
        if (!empty($params['is_home'])) {
            $query->andWhere(['=', $alias .'is_home', $params['is_home']]);
        }
        if (!empty($params['create_time'])) {
            $query->andWhere(['>=', $alias .'create_time', $params['create_time'][0]]);
            $query->andWhere(['<=', $alias .'create_time', $params['create_time'][1]]);
        }
    }
    
}
